package com.probiz.estore.common.model.sales.base;

import java.io.Serializable;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

import com.probiz.estore.common.model.catalog.GiftCategory;
import com.probiz.estore.core.model.BaseObject;

/**
 * Gift Base Java Bean, base class for the model, mapped directly to database table
 * 
 * Avoid changing this file if not necessary, will be overwritten. 
 *
 */
public class GiftTbl extends BaseObject implements Serializable {

    protected Integer giftId;
	protected String giftCode;
	protected String giftName;
	protected Short status;
	protected Short kind;
	protected Short isRecommended;
	protected Integer sortOrder;
	protected Integer minOrderQuantity;
	protected Integer maxOrderQuantity;
	protected java.util.Date startTime;
	protected java.util.Date endTime;
	protected String membership;
	protected java.math.BigDecimal price;
	protected String shortDescription;
	protected String imageUrl;
	protected Integer point;
	protected Integer weight;
	protected String weightMeasureUnitName;
	protected Integer quantityOnHand;
	protected String fullDescription;
	protected Integer allocatedQuantity;
	protected java.util.Date createTime;
	protected java.util.Date updateTime;
	protected Integer createBy;
	protected Integer updateBy;
	protected Integer version;
	protected GiftCategory category;
	
	//临时变量，存放礼品个数
	protected Integer orderSkuQuantity;

	protected java.util.Set orderSkus = new java.util.HashSet();

	/**
	 * Default Empty Constructor for class Gift
	 */
	public GiftTbl () {
		super();
	}
	
	/**
	 * Default Key Fields Constructor for class Gift
	 */
	public GiftTbl (
		 Integer in_giftId
        ) {
		this.setGiftId(in_giftId);
    }
	
	public GiftCategory getCategory() {
		return category;
	}

	public void setCategory(GiftCategory category) {
		this.category = category;
	}
	
	public java.util.Set getOrderSkus () {
		return orderSkus;
	}	
	
	public void setOrderSkus (java.util.Set in_orderSkus) {
		this.orderSkus = in_orderSkus;
	}
    

	/**
	 * 主键	 * @return Integer
     * @hibernate.id column="giftId" type="java.lang.Integer" generator-class="native"
	 */
	public Integer getGiftId() {
		return this.giftId;
	}
	
	/**
	 * Set the giftId
	 */	
	public void setGiftId(Integer aValue) {
		this.giftId = aValue;
	}	

	/**
	 * 目录外键	 * @return Integer
	 */
	public Integer getCategoryId() {
		return this.getCategory()==null?null:this.getCategory().getCategoryId();
	}
	
	/**
	 * Set the categoryId
	 */	
	public void setCategoryId(Integer aValue) {
	    if (aValue==null) {
	    	category = null;
	    } else {
	        category = new GiftCategory(aValue);
	        category.setVersion(new Integer(0));//set a version to cheat hibernate only
	    }
	}	

	/**
	 * 礼品编号	 * @return String
	 * @hibernate.property column="giftCode" type="java.lang.String" length="32" not-null="true" unique="false"
	 */
	public String getGiftCode() {
		return this.giftCode;
	}
	
	/**
	 * Set the giftCode
	 * @spring.validator type="required"
	 */	
	public void setGiftCode(String aValue) {
		this.giftCode = aValue;
	}	

	/**
	 * 礼品名称	 * @return String
	 * @hibernate.property column="giftName" type="java.lang.String" length="128" not-null="true" unique="false"
	 */
	public String getGiftName() {
		return this.giftName;
	}
	
	/**
	 * Set the giftName
	 * @spring.validator type="required"
	 */	
	public void setGiftName(String aValue) {
		this.giftName = aValue;
	}	

	/**
	 * 发布，选择项目有“是“或”否“ 
            0 = 否；1=是；-1=逻辑删除
            	 * @return Short
	 * @hibernate.property column="status" type="java.lang.Short" length="5" not-null="true" unique="false"
	 */
	public Short getStatus() {
		return this.status;
	}
	
	/**
	 * Set the status
	 * @spring.validator type="required"
	 */	
	public void setStatus(Short aValue) {
		this.status = aValue;
	}	

	/**
	 * 性质,决定是否可运输等1=实体、2=服务、3=下载、4=点卡	 * @return Short
	 * @hibernate.property column="kind" type="java.lang.Short" length="5" not-null="true" unique="false"
	 */
	public Short getKind() {
		return this.kind;
	}
	
	/**
	 * Set the kind
	 * @spring.validator type="required"
	 */	
	public void setKind(Short aValue) {
		this.kind = aValue;
	}	

	/**
	 * 作为推荐礼品，选择项目有“是“或”否“	 * @return Short
	 * @hibernate.property column="isRecommended" type="java.lang.Short" length="5" not-null="true" unique="false"
	 */
	public Short getIsRecommended() {
		return this.isRecommended;
	}
	
	/**
	 * Set the isRecommended
	 * @spring.validator type="required"
	 */	
	public void setIsRecommended(Short aValue) {
		this.isRecommended = aValue;
	}	

	/**
	 * 排序	 * @return Integer
	 * @hibernate.property column="sortOrder" type="java.lang.Integer" length="10" not-null="true" unique="false"
	 */
	public Integer getSortOrder() {
		return this.sortOrder;
	}
	
	/**
	 * Set the sortOrder
	 * @spring.validator type="required"
	 */	
	public void setSortOrder(Integer aValue) {
		this.sortOrder = aValue;
	}	

	/**
	 * 最少定购量 （预留的数据结构）	 * @return Integer
	 * @hibernate.property column="minOrderQuantity" type="java.lang.Integer" length="10" not-null="false" unique="false"
	 */
	public Integer getMinOrderQuantity() {
		return this.minOrderQuantity;
	}
	
	/**
	 * Set the minOrderQuantity
	 */	
	public void setMinOrderQuantity(Integer aValue) {
		this.minOrderQuantity = aValue;
	}	

	/**
	 * 每人限购数量，个人的限购数量设置（最大订购量）	 * @return Integer
	 * @hibernate.property column="maxOrderQuantity" type="java.lang.Integer" length="10" not-null="true" unique="false"
	 */
	public Integer getMaxOrderQuantity() {
		return this.maxOrderQuantity;
	}
	
	/**
	 * Set the maxOrderQuantity
	 * @spring.validator type="required"
	 */	
	public void setMaxOrderQuantity(Integer aValue) {
		this.maxOrderQuantity = aValue;
	}	

	/**
	 * 兑换起始时间	 * @return java.util.Date
	 * @hibernate.property column="startTime" type="java.util.Date" length="19" not-null="false" unique="false"
	 */
	public java.util.Date getStartTime() {
		return this.startTime;
	}
	
	/**
	 * Set the startTime
	 */	
	public void setStartTime(java.util.Date aValue) {
		this.startTime = aValue;
	}	

	/**
	 * 兑换终止时间	 * @return java.util.Date
	 * @hibernate.property column="endTime" type="java.util.Date" length="19" not-null="false" unique="false"
	 */
	public java.util.Date getEndTime() {
		return this.endTime;
	}
	
	/**
	 * Set the endTime
	 */	
	public void setEndTime(java.util.Date aValue) {
		this.endTime = aValue;
	}	

	/**
	 * 允许兑换的会员等级	 * @return String
	 * @hibernate.property column="membership" type="java.lang.String" length="32" not-null="true" unique="false"
	 */
	public String getMembership() {
		return this.membership;
	}
	
	/**
	 * Set the membership
	 * @spring.validator type="required"
	 */	
	public void setMembership(String aValue) {
		this.membership = aValue;
	}	

	/**
	 * 价格，礼品的单价	 * @return java.math.BigDecimal
	 * @hibernate.property column="price" type="java.math.BigDecimal" length="12" not-null="true" unique="false"
	 */
	public java.math.BigDecimal getPrice() {
		return this.price;
	}
	
	/**
	 * Set the price
	 * @spring.validator type="required"
	 */	
	public void setPrice(java.math.BigDecimal aValue) {
		this.price = aValue;
	}	

	/**
	 * 简介，对该礼品进行简单描述，如功能、作用描述	 * @return String
	 * @hibernate.property column="shortDescription" type="java.lang.String" length="512" not-null="false" unique="false"
	 */
	public String getShortDescription() {
		return this.shortDescription;
	}
	
	/**
	 * Set the shortDescription
	 */	
	public void setShortDescription(String aValue) {
		this.shortDescription = aValue;
	}	

	/**
	 * 礼品页详细图，礼品的大图	 * @return String
	 * @hibernate.property column="imageUrl" type="java.lang.String" length="255" not-null="false" unique="false"
	 */
	public String getImageUrl() {
		return this.imageUrl;
	}
	
	/**
	 * Set the imageUrl
	 */	
	public void setImageUrl(String aValue) {
		this.imageUrl = aValue;
	}	

	/**
	 * 兑换所需积分	 * @return Integer
	 * @hibernate.property column="point" type="java.lang.Integer" length="10" not-null="true" unique="false"
	 */
	public Integer getPoint() {
		return this.point;
	}
	
	/**
	 * Set the point
	 * @spring.validator type="required"
	 */	
	public void setPoint(Integer aValue) {
		this.point = aValue;
	}	

	/**
	 * 重量	 * @return Integer
	 * @hibernate.property column="weight" type="java.lang.Integer" length="10" not-null="false" unique="false"
	 */
	public Integer getWeight() {
		return this.weight;
	}
	
	/**
	 * Set the weight
	 */	
	public void setWeight(Integer aValue) {
		this.weight = aValue;
	}	

	/**
	 * 计量单位名称	 * @return String
	 * @hibernate.property column="weightMeasureUnitName" type="java.lang.String" length="32" not-null="false" unique="false"
	 */
	public String getWeightMeasureUnitName() {
		return this.weightMeasureUnitName;
	}
	
	/**
	 * Set the weightMeasureUnitName
	 */	
	public void setWeightMeasureUnitName(String aValue) {
		this.weightMeasureUnitName = aValue;
	}	

	/**
	 * 库存，等于0不予兑换，不填代表无限库存	 * @return Integer
	 * @hibernate.property column="quantityOnHand" type="java.lang.Integer" length="10" not-null="false" unique="false"
	 */
	public Integer getQuantityOnHand() {
		return this.quantityOnHand;
	}
	
	/**
	 * Set the quantityOnHand
	 */	
	public void setQuantityOnHand(Integer aValue) {
		this.quantityOnHand = aValue;
	}	

	/**
	 * 详细描述	 * @return String
	 * @hibernate.property column="fullDescription" type="java.lang.String" length="65535" not-null="false" unique="false"
	 */
	public String getFullDescription() {
		return this.fullDescription;
	}
	
	/**
	 * Set the fullDescription
	 */	
	public void setFullDescription(String aValue) {
		this.fullDescription = aValue;
	}	

	/**
	 * 冻结库存数	 * @return Integer
	 * @hibernate.property column="allocatedQuantity" type="java.lang.Integer" length="10" not-null="false" unique="false"
	 */
	public Integer getAllocatedQuantity() {
		return this.allocatedQuantity==null ? 0 : allocatedQuantity;
	}
	
	/**
	 * Set the allocatedQuantity
	 */	
	public void setAllocatedQuantity(Integer aValue) {
		this.allocatedQuantity = aValue;
	}	

	/**
	 * 创建时间	 * @return java.util.Date
	 * @hibernate.property column="createTime" type="java.util.Date" length="19" not-null="true" unique="false"
	 */
	public java.util.Date getCreateTime() {
		return this.createTime;
	}
	
	/**
	 * Set the createTime
	 * @spring.validator type="required"
	 */	
	public void setCreateTime(java.util.Date aValue) {
		this.createTime = aValue;
	}	

	/**
	 * 修改时间	 * @return java.util.Date
	 * @hibernate.property column="updateTime" type="java.util.Date" length="19" not-null="true" unique="false"
	 */
	public java.util.Date getUpdateTime() {
		return this.updateTime;
	}
	
	/**
	 * Set the updateTime
	 * @spring.validator type="required"
	 */	
	public void setUpdateTime(java.util.Date aValue) {
		this.updateTime = aValue;
	}	

	/**
	 * 创建者	 * @return Integer
	 * @hibernate.property column="createBy" type="java.lang.Integer" length="10" not-null="false" unique="false"
	 */
	public Integer getCreateBy() {
		return this.createBy;
	}
	
	/**
	 * Set the createBy
	 */	
	public void setCreateBy(Integer aValue) {
		this.createBy = aValue;
	}	

	/**
	 * 修改者	 * @return Integer
	 * @hibernate.property column="updateBy" type="java.lang.Integer" length="10" not-null="false" unique="false"
	 */
	public Integer getUpdateBy() {
		return this.updateBy;
	}
	
	/**
	 * Set the updateBy
	 */	
	public void setUpdateBy(Integer aValue) {
		this.updateBy = aValue;
	}	

	/**
	 * 修改次数	 * @return Integer
	 * @hibernate.property column="version" type="java.lang.Integer" length="10" not-null="true" unique="false"
	 */
	public Integer getVersion() {
		return this.version;
	}
	
	/**
	 * Set the version
	 * @spring.validator type="required"
	 */	
	public void setVersion(Integer aValue) {
		this.version = aValue;
	}	
	
	/**
	 * @see java.lang.Object#equals(Object)
	 */
	public boolean equals(Object object) {
		if (!(object instanceof GiftTbl)) {
			return false;
		}
		GiftTbl rhs = (GiftTbl) object;
		return new EqualsBuilder()
				.append(this.giftId, rhs.giftId)
						.append(this.giftCode, rhs.giftCode)
				.append(this.giftName, rhs.giftName)
				.append(this.status, rhs.status)
				.append(this.kind, rhs.kind)
				.append(this.isRecommended, rhs.isRecommended)
				.append(this.sortOrder, rhs.sortOrder)
				.append(this.minOrderQuantity, rhs.minOrderQuantity)
				.append(this.maxOrderQuantity, rhs.maxOrderQuantity)
				.append(this.startTime, rhs.startTime)
				.append(this.endTime, rhs.endTime)
				.append(this.membership, rhs.membership)
				.append(this.price, rhs.price)
				.append(this.shortDescription, rhs.shortDescription)
				.append(this.imageUrl, rhs.imageUrl)
				.append(this.point, rhs.point)
				.append(this.weight, rhs.weight)
				.append(this.weightMeasureUnitName, rhs.weightMeasureUnitName)
				.append(this.quantityOnHand, rhs.quantityOnHand)
				.append(this.fullDescription, rhs.fullDescription)
				.append(this.allocatedQuantity, rhs.allocatedQuantity)
				.append(this.createTime, rhs.createTime)
				.append(this.updateTime, rhs.updateTime)
				.append(this.createBy, rhs.createBy)
				.append(this.updateBy, rhs.updateBy)
				.append(this.version, rhs.version)
				.isEquals();
	}

	/**
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		return new HashCodeBuilder(-82280557, -700257973)
				.append(this.giftId) 
						.append(this.giftCode) 
				.append(this.giftName) 
				.append(this.status) 
				.append(this.kind) 
				.append(this.isRecommended) 
				.append(this.sortOrder) 
				.append(this.minOrderQuantity) 
				.append(this.maxOrderQuantity) 
				.append(this.startTime) 
				.append(this.endTime) 
				.append(this.membership) 
				.append(this.price) 
				.append(this.shortDescription) 
				.append(this.imageUrl) 
				.append(this.point) 
				.append(this.weight) 
				.append(this.weightMeasureUnitName) 
				.append(this.quantityOnHand) 
				.append(this.fullDescription) 
				.append(this.allocatedQuantity) 
				.append(this.createTime) 
				.append(this.updateTime) 
				.append(this.createBy) 
				.append(this.updateBy) 
				.append(this.version) 
				.toHashCode();
	}

	/**
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
		return new ToStringBuilder(this)
				.append("giftId", this.giftId) 
						.append("giftCode", this.giftCode) 
				.append("giftName", this.giftName) 
				.append("status", this.status) 
				.append("kind", this.kind) 
				.append("isRecommended", this.isRecommended) 
				.append("sortOrder", this.sortOrder) 
				.append("minOrderQuantity", this.minOrderQuantity) 
				.append("maxOrderQuantity", this.maxOrderQuantity) 
				.append("startTime", this.startTime) 
				.append("endTime", this.endTime) 
				.append("membership", this.membership) 
				.append("price", this.price) 
				.append("shortDescription", this.shortDescription) 
				.append("imageUrl", this.imageUrl) 
				.append("point", this.point) 
				.append("weight", this.weight) 
				.append("weightMeasureUnitName", this.weightMeasureUnitName) 
				.append("quantityOnHand", this.quantityOnHand) 
				.append("fullDescription", this.fullDescription) 
				.append("allocatedQuantity", this.allocatedQuantity) 
				.append("createTime", this.createTime) 
				.append("updateTime", this.updateTime) 
				.append("createBy", this.createBy) 
				.append("updateBy", this.updateBy) 
				.append("version", this.version) 
				.append("orderSkuQuantity", this.orderSkuQuantity)
				.toString();
	}

	/**
	 * Return the name of the first key column
	 */
	public String getFirstKeyColumnName() {
		return "giftId";
	}
	/**
	 * Return the Id (pk) of the entity, must be Integer
	 */
	public Integer getId() {
		return giftId;
	}

	public Integer getOrderSkuQuantity() {
		return orderSkuQuantity;
	}

	public void setOrderSkuQuantity(Integer orderSkuQuantity) {
		this.orderSkuQuantity = orderSkuQuantity;
	}

}